import requests
import time

def get_image():
    # with open("东方财富.text", 'w', encoding='utf8') as f:
        url = f"https://42.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112404808530809023055_1718877360859&pn={1}&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&dect=1&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1718877360895"
        response = requests.get(url)
        r = response.content.decode()
        l = r.split('jQuery112404808530809023055_1718877360859')
        l1 = l[1].split('(')
        l2 = l1[1].split(')')
        d0 = eval(l2[0])
        data = d0["data"]
        diff = data["diff"]
        for i in diff:

            print(i)
            # code = i['f12']
            # name = i['f14']
            #
            # print(f'正在写入{name}')
            #
            # f.write(f'代码{code}')
            # f.write(f'名字{name}')
            # f.write('\n')
            # time.sleep(1)


get_image()

# url = f'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
# response = requests.get(url)
# r = response.content
# with open('img.jpg','wb') as f:
#     f.write(r)